import { prompt } from 'inquirer';
import { ChallengeLang } from '../../../shared/config/curriculum';
import { challengeTypes } from '../../../shared/config/challenge-types';

export const getInputType = async (
  challengeType: string,
  challengeLang?: string
): Promise<string | undefined> => {
  const isRequired =
    parseInt(challengeType) === challengeTypes.fillInTheBlank &&
    challengeLang === ChallengeLang.Chinese;

  if (!isRequired) {
    return;
  }

  const inputType = await prompt<{ value: string }>({
    name: 'value',
    message: 'What input type is challenge using?',
    type: 'list',
    choices: ['pinyin-tone', 'pinyin-to-hanzi']
  });

  return inputType.value;
};
